use super::hitls_cert_type::HITLS_TrustedCAList;
use super::hitls_cert_type::{
    HITLS_BUILD_CHAIN_FLAG, HITLS_CERT_Chain, HITLS_CERT_Key, HITLS_CERT_Store,
    HITLS_CERT_StoreCtx, HITLS_CERT_StoreType, HITLS_CERT_X509, HITLS_ParseFormat, HITLS_ParseType,
};
use super::hitls_error::HITLS_ERROR;
use super::hitls_type::{HITLS_Config, HITLS_Ctx};
pub const HITLS_CERT_CALLBACK_SUCCESS: u32 = 1;
pub const HITLS_CERT_CALLBACK_FAILED: u32 = 0;
pub const HITLS_CERT_CALLBACK_RETRY: i32 = -1;
unsafe extern "C" {
    pub fn HITLS_CFG_SetVerifyStore(
        config: *mut HITLS_Config,
        store: *mut HITLS_CERT_Store,
        isClone: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_GetVerifyStore(config: *const HITLS_Config) -> *mut HITLS_CERT_Store;
}
unsafe extern "C" {
    pub fn HITLS_SetVerifyStore(
        ctx: *mut HITLS_Ctx,
        store: *mut HITLS_CERT_Store,
        isClone: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_GetVerifyStore(ctx: *const HITLS_Ctx) -> *mut HITLS_CERT_Store;
}
unsafe extern "C" {
    pub fn HITLS_CFG_SetChainStore(
        config: *mut HITLS_Config,
        store: *mut HITLS_CERT_Store,
        isClone: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_GetChainStore(config: *const HITLS_Config) -> *mut HITLS_CERT_Store;
}
unsafe extern "C" {
    pub fn HITLS_SetChainStore(
        ctx: *mut HITLS_Ctx,
        store: *mut HITLS_CERT_Store,
        isClone: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_GetChainStore(ctx: *const HITLS_Ctx) -> *mut HITLS_CERT_Store;
}
unsafe extern "C" {
    pub fn HITLS_CFG_SetCertStore(
        config: *mut HITLS_Config,
        store: *mut HITLS_CERT_Store,
        isClone: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_GetCertStore(config: *const HITLS_Config) -> *mut HITLS_CERT_Store;
}
unsafe extern "C" {
    pub fn HITLS_SetCertStore(
        ctx: *mut HITLS_Ctx,
        store: *mut HITLS_CERT_Store,
        isClone: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_GetCertStore(ctx: *const HITLS_Ctx) -> *mut HITLS_CERT_Store;
}
pub type HITLS_PasswordCb = ::std::option::Option<
    unsafe extern "C" fn(
        buf: *mut ::std::os::raw::c_char,
        bufLen: i32,
        flag: i32,
        userdata: *mut ::std::os::raw::c_void,
    ) -> i32,
>;
unsafe extern "C" {
    pub fn HITLS_CFG_SetDefaultPasswordCb(config: *mut HITLS_Config, cb: HITLS_PasswordCb) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_GetDefaultPasswordCb(config: *mut HITLS_Config) -> HITLS_PasswordCb;
}
unsafe extern "C" {
    pub fn HITLS_CFG_SetDefaultPasswordCbUserdata(
        config: *mut HITLS_Config,
        userdata: *mut ::std::os::raw::c_void,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_GetDefaultPasswordCbUserdata(
        config: *mut HITLS_Config,
    ) -> *mut ::std::os::raw::c_void;
}
unsafe extern "C" {
    pub fn HITLS_SetDefaultPasswordCb(ctx: *mut HITLS_Ctx, cb: HITLS_PasswordCb) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_GetDefaultPasswordCb(ctx: *mut HITLS_Ctx) -> HITLS_PasswordCb;
}
unsafe extern "C" {
    pub fn HITLS_SetDefaultPasswordCbUserdata(
        ctx: *mut HITLS_Ctx,
        userdata: *mut ::std::os::raw::c_void,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_GetDefaultPasswordCbUserdata(ctx: *mut HITLS_Ctx) -> *mut ::std::os::raw::c_void;
}
unsafe extern "C" {
    pub fn HITLS_CFG_SetTlcpCertificate(
        config: *mut HITLS_Config,
        cert: *mut HITLS_CERT_X509,
        isClone: bool,
        isTlcpEncCert: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_SetTlcpPrivateKey(
        config: *mut HITLS_Config,
        privateKey: *mut HITLS_CERT_Key,
        isClone: bool,
        isTlcpEncCertPriKey: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_SetCertificate(
        config: *mut HITLS_Config,
        cert: *mut HITLS_CERT_X509,
        isClone: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_LoadCertFile(
        config: *mut HITLS_Config,
        file: *const ::std::os::raw::c_char,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_LoadCertBuffer(
        config: *mut HITLS_Config,
        buf: *const u8,
        bufLen: u32,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_GetCertificate(config: *const HITLS_Config) -> *mut HITLS_CERT_X509;
}
unsafe extern "C" {
    pub fn HITLS_SetCertificate(
        ctx: *mut HITLS_Ctx,
        cert: *mut HITLS_CERT_X509,
        isClone: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_LoadCertFile(
        ctx: *mut HITLS_Ctx,
        file: *const ::std::os::raw::c_char,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_LoadCertBuffer(
        ctx: *mut HITLS_Ctx,
        buf: *const u8,
        bufLen: u32,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_GetCertificate(ctx: *const HITLS_Ctx) -> *mut HITLS_CERT_X509;
}
unsafe extern "C" {
    pub fn HITLS_GetPeerCertificate(ctx: *const HITLS_Ctx) -> *mut HITLS_CERT_X509;
}
unsafe extern "C" {
    pub fn HITLS_CFG_SetPrivateKey(
        config: *mut HITLS_Config,
        privateKey: *mut HITLS_CERT_Key,
        isClone: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_LoadKeyFile(
        config: *mut HITLS_Config,
        file: *const ::std::os::raw::c_char,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_ProviderLoadKeyFile(
        config: *mut HITLS_Config,
        file: *const ::std::os::raw::c_char,
        format: *const ::std::os::raw::c_char,
        type_: *const ::std::os::raw::c_char,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_LoadKeyBuffer(
        config: *mut HITLS_Config,
        buf: *const u8,
        bufLen: u32,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_ProviderLoadKeyBuffer(
        config: *mut HITLS_Config,
        buf: *const u8,
        bufLen: u32,
        format: *const ::std::os::raw::c_char,
        type_: *const ::std::os::raw::c_char,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_GetPrivateKey(config: *mut HITLS_Config) -> *mut HITLS_CERT_Key;
}
unsafe extern "C" {
    pub fn HITLS_CFG_CheckPrivateKey(config: *mut HITLS_Config) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_SetPrivateKey(ctx: *mut HITLS_Ctx, key: *mut HITLS_CERT_Key, isClone: bool)
    -> i32;
}
unsafe extern "C" {
    pub fn HITLS_LoadKeyFile(
        ctx: *mut HITLS_Ctx,
        file: *const ::std::os::raw::c_char,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_ProviderLoadKeyFile(
        ctx: *mut HITLS_Ctx,
        file: *const ::std::os::raw::c_char,
        format: *const ::std::os::raw::c_char,
        type_: *const ::std::os::raw::c_char,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_LoadKeyBuffer(
        ctx: *mut HITLS_Ctx,
        buf: *const u8,
        bufLen: u32,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_ProviderLoadKeyBuffer(
        ctx: *mut HITLS_Ctx,
        buf: *const u8,
        bufLen: u32,
        format: *const ::std::os::raw::c_char,
        type_: *const ::std::os::raw::c_char,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_GetPrivateKey(ctx: *mut HITLS_Ctx) -> *mut HITLS_CERT_Key;
}
unsafe extern "C" {
    pub fn HITLS_CheckPrivateKey(ctx: *mut HITLS_Ctx) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_AddChainCert(
        config: *mut HITLS_Config,
        cert: *mut HITLS_CERT_X509,
        isClone: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_AddCertToStore(
        config: *mut HITLS_Config,
        cert: *mut HITLS_CERT_X509,
        storeType: HITLS_CERT_StoreType,
        isClone: bool,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_ParseCert(
        config: *mut HITLS_Config,
        buf: *const u8,
        len: u32,
        type_: HITLS_ParseType,
        format: HITLS_ParseFormat,
    ) -> *mut HITLS_CERT_X509;
}
unsafe extern "C" {
    pub fn HITLS_CFG_ParseKey(
        config: *mut HITLS_Config,
        buf: *const u8,
        len: u32,
        type_: HITLS_ParseType,
        format: HITLS_ParseFormat,
    ) -> *mut HITLS_CERT_Key;
}
unsafe extern "C" {
    pub fn HITLS_CFG_ProviderParseKey(
        config: *mut HITLS_Config,
        buf: *const u8,
        len: u32,
        type_: HITLS_ParseType,
        format: *const ::std::os::raw::c_char,
        encodeType: *const ::std::os::raw::c_char,
    ) -> *mut HITLS_CERT_Key;
}
unsafe extern "C" {
    pub fn HITLS_CFG_GetChainCerts(config: *mut HITLS_Config) -> *mut HITLS_CERT_Chain;
}
unsafe extern "C" {
    pub fn HITLS_CFG_ClearChainCerts(config: *mut HITLS_Config) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_ClearChainCerts(ctx: *mut HITLS_Ctx) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_RemoveCertAndKey(config: *mut HITLS_Config) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_RemoveCertAndKey(ctx: *mut HITLS_Ctx) -> i32;
}
pub type HITLS_VerifyCb = ::std::option::Option<
    unsafe extern "C" fn(
        isPreverifyOk: i32,
        storeCtx: *mut HITLS_CERT_StoreCtx,
    ) -> ::std::os::raw::c_int,
>;
unsafe extern "C" {
    pub fn HITLS_CFG_SetVerifyCb(config: *mut HITLS_Config, callback: HITLS_VerifyCb) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_GetVerifyCb(config: *mut HITLS_Config) -> HITLS_VerifyCb;
}
unsafe extern "C" {
    pub fn HITLS_SetVerifyCb(ctx: *mut HITLS_Ctx, callback: HITLS_VerifyCb) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_GetVerifyCb(ctx: *mut HITLS_Ctx) -> HITLS_VerifyCb;
}
unsafe extern "C" {
    pub fn HITLS_SetVerifyResult(ctx: *mut HITLS_Ctx, verifyResult: HITLS_ERROR) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_GetVerifyResult(ctx: *const HITLS_Ctx, verifyResult: *mut HITLS_ERROR) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_GetPeerCertChain(ctx: *const HITLS_Ctx) -> *mut HITLS_CERT_Chain;
}
unsafe extern "C" {
    pub fn HITLS_GetPeerCAList(ctx: *const HITLS_Ctx) -> *mut HITLS_TrustedCAList;
}
unsafe extern "C" {
    pub fn HITLS_GetCAList(ctx: *const HITLS_Ctx) -> *mut HITLS_TrustedCAList;
}
unsafe extern "C" {
    pub fn HITLS_SetCAList(ctx: *mut HITLS_Ctx, list: *mut HITLS_TrustedCAList) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_AddExtraChainCert(
        config: *mut HITLS_Config,
        cert: *mut HITLS_CERT_X509,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_GetExtraChainCerts(config: *mut HITLS_Config) -> *mut HITLS_CERT_Chain;
}
unsafe extern "C" {
    pub fn HITLS_CFG_ClearExtraChainCerts(config: *mut HITLS_Config) -> i32;
}
pub type HITLS_CertCb = ::std::option::Option<
    unsafe extern "C" fn(ctx: *mut HITLS_Ctx, arg: *mut ::std::os::raw::c_void) -> i32,
>;
unsafe extern "C" {
    pub fn HITLS_CFG_SetCertCb(
        config: *mut HITLS_Config,
        certCb: HITLS_CertCb,
        arg: *mut ::std::os::raw::c_void,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_SetCertCb(
        ctx: *mut HITLS_Ctx,
        certCb: HITLS_CertCb,
        arg: *mut ::std::os::raw::c_void,
    ) -> i32;
}
pub type HITLS_KeyLogCb = ::std::option::Option<
    unsafe extern "C" fn(ctx: *mut HITLS_Ctx, line: *const ::std::os::raw::c_char),
>;
unsafe extern "C" {
    pub fn HITLS_CFG_SetKeyLogCb(config: *mut HITLS_Config, callback: HITLS_KeyLogCb) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_GetKeyLogCb(config: *mut HITLS_Config) -> HITLS_KeyLogCb;
}
unsafe extern "C" {
    pub fn HITLS_LogSecret(
        ctx: *mut HITLS_Ctx,
        label: *const ::std::os::raw::c_char,
        secret: *const u8,
        secretLen: usize,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_ParseCAList(
        config: *mut HITLS_Config,
        input: *const ::std::os::raw::c_char,
        inputLen: u32,
        inputType: HITLS_ParseType,
        format: HITLS_ParseFormat,
        caList: *mut *mut HITLS_TrustedCAList,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_BuildCertChain(config: *mut HITLS_Config, flag: HITLS_BUILD_CHAIN_FLAG)
    -> i32;
}
unsafe extern "C" {
    pub fn HITLS_BuildCertChain(ctx: *mut HITLS_Ctx, flag: HITLS_BUILD_CHAIN_FLAG) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_CtrlSetVerifyParams(
        config: *mut HITLS_Config,
        store: *mut HITLS_CERT_Store,
        cmd: u32,
        in_: i64,
        inArg: *mut ::std::os::raw::c_void,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_CtrlGetVerifyParams(
        config: *mut HITLS_Config,
        store: *mut HITLS_CERT_Store,
        cmd: u32,
        out: *mut ::std::os::raw::c_void,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CtrlSetVerifyParams(
        ctx: *mut HITLS_Ctx,
        store: *mut HITLS_CERT_Store,
        cmd: u32,
        in_: i64,
        inArg: *mut ::std::os::raw::c_void,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CtrlGetVerifyParams(
        ctx: *mut HITLS_Ctx,
        store: *mut HITLS_CERT_Store,
        cmd: u32,
        out: *mut ::std::os::raw::c_void,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_LoadCrlFile(
        config: *mut HITLS_Config,
        file: *const ::std::os::raw::c_char,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_LoadCrlBuffer(
        config: *mut HITLS_Config,
        buf: *const u8,
        bufLen: u32,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_ClearVerifyCrls(config: *mut HITLS_Config) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_LoadCrlFile(
        ctx: *mut HITLS_Ctx,
        file: *const ::std::os::raw::c_char,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_LoadCrlBuffer(
        ctx: *mut HITLS_Ctx,
        buf: *const u8,
        bufLen: u32,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_ClearVerifyCrls(ctx: *mut HITLS_Ctx) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_UseCertificateChainFile(
        ctx: *mut HITLS_Ctx,
        file: *const ::std::os::raw::c_char,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_UseCertificateChainFile(
        config: *mut HITLS_Config,
        file: *const ::std::os::raw::c_char,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_UseCertificateChainBuffer(
        config: *mut HITLS_Config,
        buf: *const u8,
        bufLen: u32,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_UseCertificateChainBuffer(
        ctx: *mut HITLS_Ctx,
        buf: *const u8,
        bufLen: u32,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_LoadVerifyFile(
        config: *mut HITLS_Config,
        file: *const ::std::os::raw::c_char,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_LoadVerifyBuffer(
        config: *mut HITLS_Config,
        buf: *const u8,
        bufLen: u32,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_LoadVerifyBuffer(
        ctx: *mut HITLS_Ctx,
        buf: *const u8,
        bufLen: u32,
        format: HITLS_ParseFormat,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_LoadVerifyDir(
        config: *mut HITLS_Config,
        path: *const ::std::os::raw::c_char,
    ) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_FreeCert(config: *mut HITLS_Config, cert: *mut HITLS_CERT_X509) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_FreeKey(config: *mut HITLS_Config, key: *mut HITLS_CERT_Key) -> i32;
}
unsafe extern "C" {
    pub fn HITLS_CFG_LoadDefaultCAPath(config: *mut HITLS_Config) -> i32;
}
